import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
import Layout from '@/Layout/Layout'

export const constantRoutes = [

    {
        path: '/',
        name: 'Home',
        component: () =>
            import ('@/pages/Home/Home')
    },
    {
        path: '/My',
        name: 'My',
        component: () =>
            import ('@/pages/My/Index')
    },
    {
        path: '/Info',
        name: 'Info',
        component: () =>
            import ('@/pages/Info/Index')
    },
    {
        path: '/creatVideo',
        name: 'creatVideo',
        component: () =>
            import ('@/pages/creatVideo/Index')
    },
    {
        path: '/login',
        name: 'login',
        component: () =>
            import ('@/pages/login/index')
    },
]

const createRouter = () => new Router({
    base: '/', // 'h5',
    mode: 'history', // require service support
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

// const router2 = new Router({
//     routes
// })

const VueRouterPush = Router.prototype.push
Router.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}
export default router
